package com.zhanghe.study.springboot.configuration.bean;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zh
 * @date 2021/9/27 16:57
 */
@WebServlet(name = "helloWorldServlet",urlPatterns = "/helloWorldServlet",
initParams = {
        @WebInitParam(name = "name",value = "张三")
})
public class HelloWorldServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = getServletConfig().getInitParameter("name");
        System.out.println("helloWorldServlet ---- doPost");
        resp.getOutputStream().println(name);
    }
}
